home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo5.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  5.9 KB  |  171 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "Disc.h"
  11.  
  12. /***********************************************************************/
  13.  
  14. long __stack = 8192;
  15. struct Library *MUIMasterBase;
  16.  
  17. /***********************************************************************/
  18.  
  19. #ifndef MAKE_ID
  20. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  21. #endif
  22.  
  23. /***********************************************************************/
  24.  
  25. struct MUIS_TheBar_Brush cbrush =
  26. {
  27.     Disc_Data,
  28.     DISC_WIDTH,
  29.     DISC_HEIGHT,
  30.     DISC_TOTALWIDTH,
  31.     0,
  32.     0,
  33.     DISC_WIDTH,
  34.     DISC_HEIGHT,
  35.     Disc_Colors,
  36.     DISC_NUMCOLORS,
  37.     DISC_TRCOLOR,
  38.     DISC_CSIZE,
  39.     DISC_FLAGS,
  40. };
  41.  
  42. struct MUIS_TheBar_Brush *brushes[] = {&cbrush,NULL};
  43.  
  44. struct MUIS_TheBar_Button buttons[] =
  45. {
  46.     {0, 0, "_Disc", "A CDRom."},
  47.     {MUIV_TheBar_End},
  48. };
  49.  
  50. char *appareances[] = {"Images and text","Images","Text",NULL};
  51. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  52.  
  53. int
  54. main(int argc,char **argv)
  55. {
  56.     int res;
  57.  
  58.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  59.     {
  60.         Object *app, *win, *bar, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  61.  
  62.         if (app = ApplicationObject,
  63.                 MUIA_Application_Title,        "TheBar Demo5",
  64.                 MUIA_Application_Version,      "$VER: TheBarDemo5 1.0 (24.6.2003)",
  65.                 MUIA_Application_Copyright,    "Copyright 2003 by Alfonso Ranieri",
  66.                 MUIA_Application_Author,       "Alfonso Ranieri <alforan@tin.it>",
  67.                 MUIA_Application_Description,  "TheBar example",
  68.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  69.  
  70.                 SubWindow, win = WindowObject,
  71.                     MUIA_Window_ID,    MAKE_ID('M','W','I','N'),
  72.                     MUIA_Window_Title, "TheBar Demo5",
  73.  
  74.                     WindowContents, VGroup,
  75.  
  76.                         Child, bar = TheBarObject,
  77.                             MUIA_Group_Horiz,        TRUE,
  78.                             MUIA_TheBar_ViewMode,    MUIV_TheBar_ViewMode_Gfx,
  79.                             MUIA_TheBar_Buttons,     buttons,
  80.                             MUIA_TheBar_Images,      brushes,
  81.                         End,
  82.                         Child, VGroup,
  83.                             GroupFrameT("Settings"),
  84.                             Child, HGroup,
  85.                                 Child, Label2("Appareance"),
  86.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  87.                                 Child, Label2("Label pos"),
  88.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  89.                             End,
  90.                             Child, HGroup,
  91.                                 Child, HSpace(0),
  92.                                 Child, Label1("Borderless"),
  93.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  94.                                 Child, HSpace(0),
  95.                                 Child, Label1("Sunny"),
  96.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  97.                                 Child, HSpace(0),
  98.                                 Child, Label1("Raised"),
  99.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  100.                                 Child, HSpace(0),
  101.                                 Child, Label1("Scaled"),
  102.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  103.                                 Child, HSpace(0),
  104.                             End,
  105.                         End,
  106.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  107.                     End,
  108.                 End,
  109.             End)
  110.         {
  111.             ULONG sigs = 0, id;
  112.  
  113.             set(appareance,MUIA_Cycle_Active,1);
  114.  
  115.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  116.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  117.  
  118.             set(win,MUIA_Window_Open,TRUE);
  119.  
  120.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  121.             {
  122.                 if (id==TAG_USER)
  123.                 {
  124.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  125.  
  126.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  127.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  128.                     get(borderless,MUIA_Selected,&borderlessV);
  129.                     get(sunny,MUIA_Selected,&sunnyV);
  130.                     get(raised,MUIA_Selected,&raisedV);
  131.                     get(scaled,MUIA_Selected,&scaledV);
  132.  
  133.                     SetAttrs(bar,MUIA_TheBar_ViewMode,   appareanceV,
  134.                                  MUIA_TheBar_LabelPos,   labelPosV,
  135.                                  MUIA_TheBar_Borderless, borderlessV,
  136.                                  MUIA_TheBar_Sunny,      sunnyV,
  137.                                  MUIA_TheBar_Raised,     raisedV,
  138.                                  MUIA_TheBar_Scaled,     scaledV,
  139.                                  TAG_DONE);
  140.                 }
  141.  
  142.                 if (sigs)
  143.                 {
  144.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  145.                     if (sigs & SIGBREAKF_CTRL_C) break;
  146.                 }
  147.             }
  148.  
  149.             MUI_DisposeObject(app);
  150.  
  151.             res = RETURN_OK;
  152.         }
  153.         else
  154.         {
  155.             printf("%s: can't create application\n",argv[0]);
  156.             res = RETURN_FAIL;
  157.         }
  158.  
  159.         CloseLibrary(MUIMasterBase);
  160.     }
  161.     else
  162.     {
  163.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  164.         res = RETURN_ERROR;
  165.     }
  166.  
  167.     return res;
  168. }
  169.  
  170. /***********************************************************************/
  171.